﻿Public Class frmChangePassword

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Me.Dispose()
    End Sub

    Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click
        If extend.Base64Sha1(txtOld.Text) = ActiveUser.PasswordHash Then
            If txtNew.Text <> txtRepeat.Text Then
                MsgBox("New password does not match repeated password", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Error")
                Exit Sub
            End If

            ActiveUser.PasswordHash = extend.Base64Sha1(txtNew.Text)
            user_registry(extend.Base64Sha1(ActiveUser.UserName)) = ActiveUser.PasswordHash
            SaveUserData()
            MsgBox("User data updated.", MsgBoxStyle.OkOnly, "Done")
            Me.Dispose()
        Else
            MsgBox("Old password is incorrect!", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Error!")
            Exit Sub
        End If
    End Sub
End Class